package cn.swenty.backstage.framework.taglib;


import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;

import cn.swenty.backstage.framework.common.Global;

/**
 * 
 * 权限控制按钮
 * 
 * @author sunyang
 *
 */
public class PermissionTag  extends BodyTagSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String code;
	
	public int doStartTag() throws JspException {
		
		boolean flag = false;
		if(Global.getCurrentUser().isAdmin()){
			flag = true;
		}else{
			flag = Global.hasCode(code);
		}
		if(flag){
			return EVAL_BODY_INCLUDE;
		}else{
			return SKIP_BODY;
		}
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}



}
